package com.ytktt.study.week7.task10.controller;

import com.ytktt.study.week7.task10.entity.DemoEntity;
import com.ytktt.study.week7.task10.service.DemoService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * demo 业务接口
 *
 * @author ytk
 */
@RestController
@RequestMapping("/demo")
@RequiredArgsConstructor
public class DemoController {

    private final DemoService demoService;

    @PostMapping
    public void saveDemo(@RequestBody DemoEntity demoEntity) {
        this.demoService.save(demoEntity);
    }

    @GetMapping
    public List<DemoEntity> listDemo() {
        return this.demoService.listDemo();
    }
}
